<!-- Copyright 2010 John L. Reilly

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.  -->

<%@ page import="java.util.List"%>
<%@ page import="com.riq.entity.Department"%>
<%@ page import="com.riq.entity.Location"%>
<%@ page import="com.riq.entity.Status"%>
<%@ page import="java.util.logging.Logger"%>
<%@ page import="java.io.IOException"%>
<%@ page import="javax.servlet.*"%>

<% 
Department d = (Department) request.getAttribute("dept");
Location l = (Location) request.getAttribute("location"); 
List<Status> statuses = (List<Status>) request.getAttribute("selectedStatuses");
System.out.println("statuses qty: " + statuses.size());
Long timeStamp = System.currentTimeMillis();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>FirstResponder</title>

<!--META-->

<meta http-equiv="content-type"  content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width" />

<!--STYLESHEET-->

<link rel="stylesheet" type="text/css" href="stylesheets/static.css" />

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">

var deptLayer =  null;
var map;
var marker;

function initialize() {
  var myLatlng = 
    new google.maps.LatLng(<%=l.getlastLat()%>,<%=l.getlastLng()%>);
  var myOptions = {
    zoom: 18,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.HYBRID
  }

  var timestamp = new Date().getTime();
  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  
  marker = new google.maps.Marker({
      position: myLatlng, 
      map: map,
      draggable: false
  });
  
  google.maps.event.addListener(marker, 'position_changed', showPosition);
  showPosition();
}


function showPosition() {
  document.getElementById("latitude").innerHTML  = marker.getPosition().lat();
  document.getElementById("longitude").innerHTML = marker.getPosition().lng(); 
  document.getElementById("lat").value = marker.getPosition().lat();
  document.getElementById("lng").value = marker.getPosition().lng(); 
}


function show_hide(show, hide)
{
document.getElementById(show).style.display="block";
document.getElementById(hide).style.display="none";
}

</script>

</head>
<body onload="initialize()">

<!--FIXED HEADERS-->

<div class="headwrap">
<div class="hBlack">
<div class="headerLeftTop">FirstResponder</div>
<div class="headerRightTop">ver 0.9</div>
<div class="headerLeftBottom">Location: Display</div>
<div class="headerRightBottom">Main</div>
</div>

<div class="hGray">
  <a class="buttonGrayHdr" href="mainMenu.html">Main</a>
  <a class="buttonGrayHdr" href="commandMenu.html">Command</a>
  <a class="buttonGrayHdr gSelected" href="department?action=display">Admin</a>
</div>

<div class="headerMist"></div>
</div>

<!--PAGE CONTENT-->

<div class="outwrap">
<div class="headerPlug"></div>

<!--BUTTONS-->

<div id="centeredButtons"><ul><li>
<a class="button blue wide tall first"
   href="department?action=display">
   Back
</a></li></ul></div>
<div id="centeredButtons"><ul><li>
<a class="button red narrow tall last"
   href="location?action=delete&locationId=<%=l.getid().toString()%>">
   Delete<p></p>Location
</a></li><li>
<a class="button green narrow tall last"
   href="location?action=edit&locationId=<%=l.getid().toString()%>&deptId=<%=d.getid().toString()%>">
   Edit<p></p>Location
</a></li></ul></div>

<div class="sub black">Location</div>

<div class="row title">Short Name: </div>
<div class="row" style="clear: none"> <%=l.getshortName()%></div>
<div class="row title">Long Name: </div>
<div class="row" style="clear: none"> <%=l.getlongName()%></div>
<div class="row title">Type: </div>
<div class="row" style="clear: none"><%=l.gettype()%></div>
<div class="row title">Sequence:  </div>
<div class="row" style="clear: none"><%=l.getsequence()%></div>
<div class="row title">Position: </div>
<div class="row" style="clear: none"><%=l.getposition()%></div>

<% if ("dynamic".equalsIgnoreCase(l.getposition())) { %>
<div id="dynamic" style="display: block">  
<% } else { %>
<div id="dynamic" style="display: none">  
<% }  %>
<div class="row title">Latitude ID (optional):</div>
<div class="row" style="clear: none"><%=l.getlatitudeId()%></div>
</div>

<% if ("static".equalsIgnoreCase(l.getposition())) { %>
<div id="static" style="display: block">  
<% } else { %>
<div id="static" style="display: none">  
<% }  %>
<div class="sub black">Static Position:</div> 
<div class="mapWrapper" style="width: 100%; padding: 10px;">
<div style="height: 400px; width: 100%; clear:left; float: left" id="map_canvas"></div>
</div>
<div class="row" style="min-width: 250px">Dept Latitude:</div>
<div id="latitude" class="row" style="clear: none; width: 40%; overflow: hidden"></div>
<div class="row" style="min-width: 250px">Dept Longitude:</div>
<div id="longitude" class="row" style="clear: none; width: 40%; overflow: hidden"></div>
</div>


<div class="row title">Special?: </div>
<div class="row" style="clear: none"><%=l.getspecial()%></div>
<div class="row title">VRU: </div>
<div class="row" style="clear: none"><%=l.getvru()%></div>-

<div class="sub black">Associated Status List</div>
<%  
	String tempLocType = "init";
	
	if (statuses != null) {
	  for (Status s : statuses) {
		  if (!s.gettype().equals(tempLocType)) { %>
			  <div class="sub white"><%=s.gettype()%></div>
		    <% } %>
    <div class="row"><%=s.getshortName() %></div> 
    <% tempLocType = s.gettype();
	  }
	} else { %>
	<div class="row">
	No Statuses are currently associated with this Location
	</div>
	<% }
	%>

<div class="hints">Quick Hints:</div>
<div class="reportWrapper">
Position: This field refers to whether or not this Location is geographically fixed.  For instance,
a firehouse, hospital or draft site would have fixed gps coordinates where a vehicle would not.
</div>

<!--FOOTER-->
<div class="footer">FirstResponder</div>

<!--OUTLINE WRAPPER -->
</div> 

</body>
</html>
